FROM ubuntu:22.04

# 设置时区
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo Asia/Shanghai > /etc/timezone

# 更新软件源
RUN sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list

WORKDIR /app
COPY . /app/

RUN set -x \
    && apt-get update --fix-missing \
    # 添加 deadsnakes PPA 源
    && apt-get install -y software-properties-common \
    && add-apt-repository -y ppa:deadsnakes/ppa \
    && apt-get update \
    && apt-get install -y vim wget unzip curl \
    && apt-get install -y libgl1 \
    && apt-get install -y libglib2.0-0 \
    && apt-get install -y python3-pip \
    && apt-get install -y python3.11 \
    && ln -sf /usr/bin/python3.11 /usr/bin/python3 \
    && ln -sf /usr/bin/python3.11 /usr/bin/python \
    && pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/ \
    && pip install --no-cache-dir -r requirements.txt \
    # 清理缓存
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* \
    && mkdir -p /opt/tempFile \
    && chmod 777 /opt/tempFile


EXPOSE 8000

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000", "--settings=MaterialCenter.settings.prod"]